/**
 * Created by Qiao.Yin on 2016/9/28.
 */
"use strict";
let request = require("../../common/util/request"),
    config = require('../../config');


var productService = function () {

};

productService.prototype = {
    /**
     * 根据ID获取商品详情
     * @param params
     */
    getDetail: function *(params) {
        let res = yield request.ajaxTransfer({
            method: 'post',
            uri: `${config.apiHost.uri}/api/Crowdfunding/Item/GetItem/${params['id']}`,
            headerType: 'Bearer',
            token: params['token']
        });
        return res.body;
    },
    /**
     * 获取分类类别
     * @param params
     * @returns {*}
     */
    getCates: function *(params) {
        let res = yield request.ajaxTransfer({
            method: 'post',
            uri: `${config.apiHost.uri}/api/Crowdfunding/Product/GetProductClses`,
            headerType: 'Bearer',
            token: params['token']
        });
        return res.body;
    },
    /**
     * 根据id查询分类列表
     * @param params
     * @returns {*}
     */
    getCatePagesByProductId: function *(params) {
        let res = yield request.ajaxTransfer({
            method: 'post',
            uri: `${config.apiHost.uri}/api/Crowdfunding/Item/GetItemPagesByProductCls`,
            headerType: 'Bearer',
            token: params['token'],
            params: {
                Id: params['id'],
                Page: params['page'],
                PageSize: params['pageSize']
            }
        });
        return res.body;
    },
    /**
     * 提交支付信息
     * @param params
     * @returns {*}
     */
    itemOrder : function *(params) {
        let res = yield request.ajaxTransfer({
            method: 'post',
            uri: `${config.apiHost.uri}/api/Crowdfunding/Item/ItemOrder`,
            headerType: 'Bearer',
            token: params['token'],
            params: {
                OrderType: params['OrderType'],
                IsAutoOrder: params['IsAutoOrder'],
                PayDatas: params['PayDatas'],
                OrderCount: params['OrderCount'],
                ItemId: params['ItemId']
            }
        });
        return res.body;
    }
};


module.exports = new productService();